<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-comment">-- |</span><span>
</span><span id="line-2"></span><span class="hs-comment">-- Module      : Data.Text.Internal.Read</span><span>
</span><span id="line-3"></span><span class="hs-comment">-- Copyright   : (c) 2014 Bryan O'Sullivan</span><span>
</span><span id="line-4"></span><span class="hs-comment">--</span><span>
</span><span id="line-5"></span><span class="hs-comment">-- License     : BSD-style</span><span>
</span><span id="line-6"></span><span class="hs-comment">-- Maintainer  : bos@serpentine.com</span><span>
</span><span id="line-7"></span><span class="hs-comment">-- Stability   : experimental</span><span>
</span><span id="line-8"></span><span class="hs-comment">-- Portability : GHC</span><span>
</span><span id="line-9"></span><span class="hs-comment">--</span><span>
</span><span id="line-10"></span><span class="hs-comment">-- Common internal functions for reading textual data.</span><span>
</span><span id="line-11"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">Data.Text.Internal.Read</span><span>
</span><span id="line-12"></span><span>    </span><span class="hs-special">(</span><span>
</span><span id="line-13"></span><span>      </span><span class="annot"><a href="Data.Text.Internal.Read.html#IReader"><span class="hs-identifier">IReader</span></a></span><span>
</span><span id="line-14"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.Internal.Read.html#IParser"><span class="hs-identifier">IParser</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span>
</span><span id="line-15"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.Internal.Read.html#T"><span class="hs-identifier">T</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span>
</span><span id="line-16"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.Internal.Read.html#digitToInt"><span class="hs-identifier">digitToInt</span></a></span><span>
</span><span id="line-17"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.Internal.Read.html#hexDigitToInt"><span class="hs-identifier">hexDigitToInt</span></a></span><span>
</span><span id="line-18"></span><span>    </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Data.Text.Internal.Read.html#perhaps"><span class="hs-identifier">perhaps</span></a></span><span>
</span><span id="line-19"></span><span>    </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-20"></span><span>
</span><span id="line-21"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Control.Applicative.html#"><span class="hs-identifier">Control.Applicative</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">App</span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Base.html#Applicative"><span class="hs-identifier">Applicative</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-22"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Control.Arrow.html#"><span class="hs-identifier">Control.Arrow</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Control.Arrow.html#first"><span class="hs-identifier">first</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-23"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.html#"><span class="hs-identifier">Control.Monad</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Base.html#ap"><span class="hs-identifier">ap</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-24"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.Char.html#"><span class="hs-identifier">Data.Char</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Base.html#ord"><span class="hs-identifier">ord</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-25"></span><span>
</span><span id="line-26"></span><span class="hs-keyword">type</span><span> </span><span id="IReader"><span class="annot"><a href="Data.Text.Internal.Read.html#IReader"><span class="hs-identifier hs-var">IReader</span></a></span></span><span> </span><span id="local-6989586621679104407"><span class="annot"><a href="#local-6989586621679104407"><span class="hs-identifier hs-type">t</span></a></span></span><span> </span><span id="local-6989586621679104406"><span class="annot"><a href="#local-6989586621679104406"><span class="hs-identifier hs-type">a</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="#local-6989586621679104407"><span class="hs-identifier hs-type">t</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/Data.Either.html#Either"><span class="hs-identifier hs-type">Either</span></a></span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679104406"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">,</span><span class="annot"><a href="#local-6989586621679104407"><span class="hs-identifier hs-type">t</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-27"></span><span>
</span><span id="line-28"></span><span class="hs-keyword">newtype</span><span> </span><span id="IParser"><span class="annot"><a href="Data.Text.Internal.Read.html#IParser"><span class="hs-identifier hs-var">IParser</span></a></span></span><span> </span><span id="local-6989586621679104496"><span class="annot"><a href="#local-6989586621679104496"><span class="hs-identifier hs-type">t</span></a></span></span><span> </span><span id="local-6989586621679104495"><span class="annot"><a href="#local-6989586621679104495"><span class="hs-identifier hs-type">a</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="P"><span class="annot"><a href="Data.Text.Internal.Read.html#P"><span class="hs-identifier hs-var">P</span></a></span></span><span> </span><span class="hs-special">{</span><span>
</span><span id="line-29"></span><span>      </span><span id="runP"><span class="annot"><span class="annottext">forall t a. IParser t a -&gt; IReader t a
</span><a href="Data.Text.Internal.Read.html#runP"><span class="hs-identifier hs-var hs-var">runP</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Data.Text.Internal.Read.html#IReader"><span class="hs-identifier hs-type">IReader</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679104496"><span class="hs-identifier hs-type">t</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679104495"><span class="hs-identifier hs-type">a</span></a></span><span>
</span><span id="line-30"></span><span>    </span><span class="hs-special">}</span><span>
</span><span id="line-31"></span><span>
</span><span id="line-32"></span><span id="local-6989586621679104486"><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621679104401"><span class="annot"><a href="../../base/src/GHC.Base.html#Functor"><span class="hs-identifier hs-type">Functor</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Data.Text.Internal.Read.html#IParser"><span class="hs-identifier hs-type">IParser</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679104486"><span class="hs-identifier hs-type">t</span></a></span><span class="hs-special">)</span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-33"></span><span>    </span><span id="local-6989586621679104395"><span class="annot"><span class="annottext">fmap :: forall a b. (a -&gt; b) -&gt; IParser t a -&gt; IParser t b
</span><a href="../../base/src/GHC.Base.html#fmap"><span class="hs-identifier hs-var hs-var hs-var hs-var">fmap</span></a></span></span><span> </span><span id="local-6989586621679104394"><span class="annot"><span class="annottext">a -&gt; b
</span><a href="#local-6989586621679104394"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span id="local-6989586621679104393"><span class="annot"><span class="annottext">IParser t a
</span><a href="#local-6989586621679104393"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IReader t b -&gt; IParser t b
forall t a. IReader t a -&gt; IParser t a
</span><a href="Data.Text.Internal.Read.html#P"><span class="hs-identifier hs-var">P</span></a></span><span> </span><span class="annot"><span class="annottext">(IReader t b -&gt; IParser t b) -&gt; IReader t b -&gt; IParser t b
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">((a, t) -&gt; (b, t)) -&gt; Either String (a, t) -&gt; Either String (b, t)
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/GHC.Base.html#fmap"><span class="hs-identifier hs-var">fmap</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(a -&gt; b) -&gt; (a, t) -&gt; (b, t)
forall (a :: * -&gt; * -&gt; *) b c d.
Arrow a =&gt;
a b c -&gt; a (b, d) (c, d)
</span><a href="../../base/src/Control.Arrow.html#first"><span class="hs-identifier hs-var">first</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; b
</span><a href="#local-6989586621679104394"><span class="hs-identifier hs-var">f</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(Either String (a, t) -&gt; Either String (b, t))
-&gt; (t -&gt; Either String (a, t)) -&gt; IReader t b
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">IParser t a -&gt; t -&gt; Either String (a, t)
forall t a. IParser t a -&gt; IReader t a
</span><a href="Data.Text.Internal.Read.html#runP"><span class="hs-identifier hs-var hs-var">runP</span></a></span><span> </span><span class="annot"><span class="annottext">IParser t a
</span><a href="#local-6989586621679104393"><span class="hs-identifier hs-var">m</span></a></span></span><span>
</span><span id="line-34"></span><span>
</span><span id="line-35"></span><span id="local-6989586621679104460"><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621679104382"><span id="local-6989586621679104384"><span id="local-6989586621679104386"><span class="annot"><a href="../../base/src/GHC.Base.html#Applicative"><span class="hs-identifier hs-type">Applicative</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Data.Text.Internal.Read.html#IParser"><span class="hs-identifier hs-type">IParser</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679104460"><span class="hs-identifier hs-type">t</span></a></span><span class="hs-special">)</span></span></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-36"></span><span>    </span><span id="local-6989586621679104380"><span class="annot"><span class="annottext">pure :: forall a. a -&gt; IParser t a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var hs-var hs-var hs-var">pure</span></a></span></span><span> </span><span id="local-6989586621679104379"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679104379"><span class="hs-identifier hs-var">a</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IReader t a -&gt; IParser t a
forall t a. IReader t a -&gt; IParser t a
</span><a href="Data.Text.Internal.Read.html#P"><span class="hs-identifier hs-var">P</span></a></span><span> </span><span class="annot"><span class="annottext">(IReader t a -&gt; IParser t a) -&gt; IReader t a -&gt; IParser t a
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679104378"><span class="annot"><span class="annottext">t
</span><a href="#local-6989586621679104378"><span class="hs-identifier hs-var">t</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">(a, t) -&gt; Either String (a, t)
forall a b. b -&gt; Either a b
</span><a href="../../base/src/Data.Either.html#Right"><span class="hs-identifier hs-var">Right</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679104379"><span class="hs-identifier hs-var">a</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">t
</span><a href="#local-6989586621679104378"><span class="hs-identifier hs-var">t</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-37"></span><span>    </span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#pure"><span class="hs-pragma hs-type">pure</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-38"></span><span>    </span><span id="local-6989586621679104376"><span class="annot"><span class="annottext">&lt;*&gt; :: forall a b. IParser t (a -&gt; b) -&gt; IParser t a -&gt; IParser t b
</span><a href="../../base/src/GHC.Base.html#%3C%2A%3E"><span class="hs-operator hs-var hs-var hs-var hs-var">(&lt;*&gt;)</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IParser t (a -&gt; b) -&gt; IParser t a -&gt; IParser t b
forall (m :: * -&gt; *) a b. Monad m =&gt; m (a -&gt; b) -&gt; m a -&gt; m b
</span><a href="../../base/src/GHC.Base.html#ap"><span class="hs-identifier hs-var">ap</span></a></span></span><span>
</span><span id="line-39"></span><span>
</span><span id="line-40"></span><span id="local-6989586621679104456"><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621679104371"><span class="annot"><a href="../../base/src/GHC.Base.html#Monad"><span class="hs-identifier hs-type">Monad</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Data.Text.Internal.Read.html#IParser"><span class="hs-identifier hs-type">IParser</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679104456"><span class="hs-identifier hs-type">t</span></a></span><span class="hs-special">)</span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-41"></span><span>    </span><span id="local-6989586621679104367"><span class="annot"><span class="annottext">return :: forall a. a -&gt; IParser t a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var hs-var hs-var hs-var">return</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">a -&gt; IParser t a
forall (f :: * -&gt; *) a. Applicative f =&gt; a -&gt; f a
</span><a href="../../base/src/GHC.Base.html#pure"><span class="hs-identifier hs-var">App.pure</span></a></span><span>
</span><span id="line-42"></span><span>    </span><span id="local-6989586621679104366"><span class="annot"><span class="annottext">IParser t a
</span><a href="#local-6989586621679104366"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span id="local-6989586621679104365"><span class="annot"><span class="annottext">&gt;&gt;= :: forall a b. IParser t a -&gt; (a -&gt; IParser t b) -&gt; IParser t b
</span><a href="../../base/src/GHC.Base.html#%3E%3E%3D"><span class="hs-operator hs-var hs-var hs-var hs-var">&gt;&gt;=</span></a></span></span><span> </span><span id="local-6989586621679104364"><span class="annot"><span class="annottext">a -&gt; IParser t b
</span><a href="#local-6989586621679104364"><span class="hs-identifier hs-var">k</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IReader t b -&gt; IParser t b
forall t a. IReader t a -&gt; IParser t a
</span><a href="Data.Text.Internal.Read.html#P"><span class="hs-identifier hs-var">P</span></a></span><span> </span><span class="annot"><span class="annottext">(IReader t b -&gt; IParser t b) -&gt; IReader t b -&gt; IParser t b
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679104363"><span class="annot"><span class="annottext">t
</span><a href="#local-6989586621679104363"><span class="hs-identifier hs-var">t</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">IParser t a -&gt; IReader t a
forall t a. IParser t a -&gt; IReader t a
</span><a href="Data.Text.Internal.Read.html#runP"><span class="hs-identifier hs-var hs-var">runP</span></a></span><span> </span><span class="annot"><span class="annottext">IParser t a
</span><a href="#local-6989586621679104366"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">t
</span><a href="#local-6989586621679104363"><span class="hs-identifier hs-var">t</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-43"></span><span>                           </span><span class="annot"><a href="../../base/src/Data.Either.html#Left"><span class="hs-identifier hs-type">Left</span></a></span><span> </span><span id="local-6989586621679104362"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679104362"><span class="hs-identifier hs-var">err</span></a></span></span><span>     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; Either String (b, t)
forall a b. a -&gt; Either a b
</span><a href="../../base/src/Data.Either.html#Left"><span class="hs-identifier hs-var">Left</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679104362"><span class="hs-identifier hs-var">err</span></a></span><span>
</span><span id="line-44"></span><span>                           </span><span class="annot"><a href="../../base/src/Data.Either.html#Right"><span class="hs-identifier hs-type">Right</span></a></span><span> </span><span class="hs-special">(</span><span id="local-6989586621679104361"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679104361"><span class="hs-identifier hs-var">a</span></a></span></span><span class="hs-special">,</span><span id="local-6989586621679104360"><span class="annot"><span class="annottext">t
</span><a href="#local-6989586621679104360"><span class="hs-identifier hs-var">t'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">IParser t b -&gt; IReader t b
forall t a. IParser t a -&gt; IReader t a
</span><a href="Data.Text.Internal.Read.html#runP"><span class="hs-identifier hs-var hs-var">runP</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a -&gt; IParser t b
</span><a href="#local-6989586621679104364"><span class="hs-identifier hs-var">k</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679104361"><span class="hs-identifier hs-var">a</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">t
</span><a href="#local-6989586621679104360"><span class="hs-identifier hs-var">t'</span></a></span><span>
</span><span id="line-45"></span><span>    </span><span class="hs-pragma">{-# INLINE</span><span> </span><span class="hs-pragma">(</span><span class="hs-pragma">&gt;&gt;=</span><span class="hs-pragma">)</span><span> </span><span class="hs-pragma">#-}</span></span><span>
</span><span id="line-46"></span><span>
</span><span id="line-47"></span><span class="hs-comment">-- If we ever need a `MonadFail` instance the definition below can be used</span><span>
</span><span id="line-48"></span><span class="hs-comment">--</span><span>
</span><span id="line-49"></span><span class="hs-comment">-- &gt; instance MonadFail (IParser t) where</span><span>
</span><span id="line-50"></span><span class="hs-comment">-- &gt;   fail msg = P $ \_ -&gt; Left msg</span><span>
</span><span id="line-51"></span><span class="hs-comment">--</span><span>
</span><span id="line-52"></span><span class="hs-comment">-- But given the code compiles fine with a post-MFP GHC 8.6+ we don't need</span><span>
</span><span id="line-53"></span><span class="hs-comment">-- one just yet.</span><span>
</span><span id="line-54"></span><span>
</span><span id="line-55"></span><span class="hs-keyword">data</span><span> </span><span id="T"><span class="annot"><a href="Data.Text.Internal.Read.html#T"><span class="hs-identifier hs-var">T</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="T"><span class="annot"><a href="Data.Text.Internal.Read.html#T"><span class="hs-identifier hs-var">T</span></a></span></span><span> </span><span class="hs-glyph">!</span><span class="annot"><span class="hs-identifier hs-type">Integer</span></span><span> </span><span class="hs-glyph">!</span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span>
</span><span id="line-56"></span><span>
</span><span id="line-57"></span><span id="local-6989586621679104440"><span id="local-6989586621679104441"><span class="annot"><a href="Data.Text.Internal.Read.html#perhaps"><span class="hs-identifier hs-type">perhaps</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="#local-6989586621679104441"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Data.Text.Internal.Read.html#IParser"><span class="hs-identifier hs-type">IParser</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679104440"><span class="hs-identifier hs-type">t</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679104441"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Data.Text.Internal.Read.html#IParser"><span class="hs-identifier hs-type">IParser</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679104440"><span class="hs-identifier hs-type">t</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679104441"><span class="hs-identifier hs-type">a</span></a></span></span></span><span>
</span><span id="line-58"></span><span id="perhaps"><span class="annot"><span class="annottext">perhaps :: forall a t. a -&gt; IParser t a -&gt; IParser t a
</span><a href="Data.Text.Internal.Read.html#perhaps"><span class="hs-identifier hs-var hs-var">perhaps</span></a></span></span><span> </span><span id="local-6989586621679104358"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679104358"><span class="hs-identifier hs-var">def</span></a></span></span><span> </span><span id="local-6989586621679104357"><span class="annot"><span class="annottext">IParser t a
</span><a href="#local-6989586621679104357"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">IReader t a -&gt; IParser t a
forall t a. IReader t a -&gt; IParser t a
</span><a href="Data.Text.Internal.Read.html#P"><span class="hs-identifier hs-var">P</span></a></span><span> </span><span class="annot"><span class="annottext">(IReader t a -&gt; IParser t a) -&gt; IReader t a -&gt; IParser t a
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621679104356"><span class="annot"><span class="annottext">t
</span><a href="#local-6989586621679104356"><span class="hs-identifier hs-var">t</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">IParser t a -&gt; IReader t a
forall t a. IParser t a -&gt; IReader t a
</span><a href="Data.Text.Internal.Read.html#runP"><span class="hs-identifier hs-var hs-var">runP</span></a></span><span> </span><span class="annot"><span class="annottext">IParser t a
</span><a href="#local-6989586621679104357"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">t
</span><a href="#local-6989586621679104356"><span class="hs-identifier hs-var">t</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-59"></span><span>                            </span><span class="annot"><a href="../../base/src/Data.Either.html#Left"><span class="hs-identifier hs-type">Left</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-identifier">_</span></span><span>      </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">(a, t) -&gt; Either String (a, t)
forall a b. b -&gt; Either a b
</span><a href="../../base/src/Data.Either.html#Right"><span class="hs-identifier hs-var">Right</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679104358"><span class="hs-identifier hs-var">def</span></a></span><span class="hs-special">,</span><span class="annot"><span class="annottext">t
</span><a href="#local-6989586621679104356"><span class="hs-identifier hs-var">t</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-60"></span><span>                            </span><span id="local-6989586621679104355"><span class="annot"><span class="annottext">r :: Either String (a, t)
</span><a href="#local-6989586621679104355"><span class="hs-identifier hs-var">r</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Data.Either.html#Right"><span class="hs-identifier hs-type">Right</span></a></span><span> </span><span class="annot"><span class="annottext">(a, t)
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Either String (a, t)
</span><a href="#local-6989586621679104355"><span class="hs-identifier hs-var">r</span></a></span><span>
</span><span id="line-61"></span><span>
</span><span id="line-62"></span><span class="annot"><a href="Data.Text.Internal.Read.html#hexDigitToInt"><span class="hs-identifier hs-type">hexDigitToInt</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Char"><span class="hs-identifier hs-type">Char</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span>
</span><span id="line-63"></span><span id="hexDigitToInt"><span class="annot"><span class="annottext">hexDigitToInt :: Char -&gt; Int
</span><a href="Data.Text.Internal.Read.html#hexDigitToInt"><span class="hs-identifier hs-var hs-var">hexDigitToInt</span></a></span></span><span> </span><span id="local-6989586621679104354"><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679104354"><span class="hs-identifier hs-var">c</span></a></span></span><span>
</span><span id="line-64"></span><span>    </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679104354"><span class="hs-identifier hs-var">c</span></a></span><span> </span><span class="annot"><span class="annottext">Char -&gt; Char -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3E%3D"><span class="hs-operator hs-var">&gt;=</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'0'</span></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%26%26"><span class="hs-operator hs-var">&amp;&amp;</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679104354"><span class="hs-identifier hs-var">c</span></a></span><span> </span><span class="annot"><span class="annottext">Char -&gt; Char -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3C%3D"><span class="hs-operator hs-var">&lt;=</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'9'</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Char -&gt; Int
</span><a href="../../base/src/GHC.Base.html#ord"><span class="hs-identifier hs-var">ord</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679104354"><span class="hs-identifier hs-var">c</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span> </span><span class="annot"><span class="annottext">Char -&gt; Int
</span><a href="../../base/src/GHC.Base.html#ord"><span class="hs-identifier hs-var">ord</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'0'</span></span><span>
</span><span id="line-65"></span><span>    </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679104354"><span class="hs-identifier hs-var">c</span></a></span><span> </span><span class="annot"><span class="annottext">Char -&gt; Char -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3E%3D"><span class="hs-operator hs-var">&gt;=</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'a'</span></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%26%26"><span class="hs-operator hs-var">&amp;&amp;</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679104354"><span class="hs-identifier hs-var">c</span></a></span><span> </span><span class="annot"><span class="annottext">Char -&gt; Char -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><a href="../../ghc-prim/src/GHC.Classes.html#%3C%3D"><span class="hs-operator hs-var">&lt;=</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'f'</span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Char -&gt; Int
</span><a href="../../base/src/GHC.Base.html#ord"><span class="hs-identifier hs-var">ord</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679104354"><span class="hs-identifier hs-var">c</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Char -&gt; Int
</span><a href="../../base/src/GHC.Base.html#ord"><span class="hs-identifier hs-var">ord</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'a'</span></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">10</span></span><span class="hs-special">)</span><span>
</span><span id="line-66"></span><span>    </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>            </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Char -&gt; Int
</span><a href="../../base/src/GHC.Base.html#ord"><span class="hs-identifier hs-var">ord</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679104354"><span class="hs-identifier hs-var">c</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Char -&gt; Int
</span><a href="../../base/src/GHC.Base.html#ord"><span class="hs-identifier hs-var">ord</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'A'</span></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">10</span></span><span class="hs-special">)</span><span>
</span><span id="line-67"></span><span>
</span><span id="line-68"></span><span class="annot"><a href="Data.Text.Internal.Read.html#digitToInt"><span class="hs-identifier hs-type">digitToInt</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Char"><span class="hs-identifier hs-type">Char</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../ghc-prim/src/GHC.Types.html#Int"><span class="hs-identifier hs-type">Int</span></a></span><span>
</span><span id="line-69"></span><span id="digitToInt"><span class="annot"><span class="annottext">digitToInt :: Char -&gt; Int
</span><a href="Data.Text.Internal.Read.html#digitToInt"><span class="hs-identifier hs-var hs-var">digitToInt</span></a></span></span><span> </span><span id="local-6989586621679104351"><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679104351"><span class="hs-identifier hs-var">c</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Char -&gt; Int
</span><a href="../../base/src/GHC.Base.html#ord"><span class="hs-identifier hs-var">ord</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><a href="#local-6989586621679104351"><span class="hs-identifier hs-var">c</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span> </span><span class="annot"><span class="annottext">Char -&gt; Int
</span><a href="../../base/src/GHC.Base.html#ord"><span class="hs-identifier hs-var">ord</span></a></span><span> </span><span class="annot"><span class="annottext">Char
</span><span class="hs-char">'0'</span></span><span>
</span><span id="line-70"></span></pre></body></html>